package com.cdcas;

public class Book1 implements Comparable<Book1>{
    private String title;
    private String author;
    private double price;
    public Book1(String title,String author,double price) {
        this.title = title;
        this.author = author;
        this.price = price;
    }

    @Override
    public String toString() {
        return "Book1{" +
                "title='" + title + '\'' +
                ", author='" + author + '\'' +
                ", price=" + price +
                '}';
    }

    @Override
    public int compareTo(Book1 o) {
        if (this.price > o.price) {
            return 1;
        } else if (this.price < o.price) {
            return -1;
        } else {
            if (this.title.compareTo(o.title)>0) {
                return 1;
            } else if (this.title.compareTo(o.title) <0) {
                return -1;
            }else {
                if (this.author.compareTo(o.author)>0) {
                    return 1;
                } else if (this.author.compareTo(o.author) <0) {
                    return -1;
                } else{
                    return 0;
                }
            }

        }
    }
}
